<template>
	<view class="editUserInfoContainer">
		<input type="text" :placeholder="placeholderVal" v-model="inputVal" class="editInputBox" />
		<button class="editUserInfoBtn" @click="editUserInfo()">确定</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageType: 1,
				placeholderVal: '请输入……',
				inputVal: '',
				pageTitle: '',
			}
		},
		onLoad(options) {
			this.pageType = options.type;
			this.inputVal = options.inputVal;
			if(options.type == 1){
				this.pageTitle = '名字';
				uni.setNavigationBarTitle({
					title: '名字'
				})
			}else if(options.type == 2){
				this.pageTitle = '手机';
				uni.setNavigationBarTitle({
					title: '手机'
				})
			}else if(options.type == 3){
				this.pageTitle = '邮箱';
				uni.setNavigationBarTitle({
					title: '邮箱'
				})
			}
			this.placeholderVal = '请输入'+this.pageTitle;
		},
		methods: {
			editUserInfo() {
				let _this = this;
				let params = {
					token: getApp().globalData.token
				}
				if(this.inputVal == '') {
					uni.showToast({
						title: `请输入${_this.pageTitle}！`,
						icon: 'none'
					})
					return;
				}
				if(this.pageType == 1) {
					params.userName = this.inputVal;
				}else if(this.pageType == 2) {
					params.mobilePhone = this.inputVal;
				}else if(this.pageType == 3) {
					params.email = this.inputVal;
				}
				this.$utils.requestFun('/member/memberSchoolUsers/api/updateMemberUser?route=member',params,'GET').then(res=> {
					uni.showToast({
						title: '修改成功',
						success() {
							setTimeout(()=> {
								uni.navigateBack({
								    delta: 1
								});
							},1000)
						}
					})
				})
			}
		}
	}
</script>

<style>
	.editUserInfoContainer {
		width: 100%;
		height: 100vh;
		background: #FFFFFF;
	}
	.txtOverFlow {
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
	}
	.flex {
		display: flex;
	}
	.editInputBox {
		background-color: #F6F6F6;
		width: 89%;
		height: 100rpx;
		border-radius: 50rpx;
		margin: 32rpx 24rpx 60rpx 24rpx;
		padding-left: 33rpx;
	}
	.editUserInfoBtn {
		width: 93%;
		height: 98rpx;
		margin: 0 24rpx;
		background: linear-gradient(90deg, #19AD78, #1EBE85);
		border-radius: 49rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 98rpx;
	}
</style>
